Log In  
[back to top]

[ :: Read More :: ]

Since working on compressing text in a simple bookreader:

https://www.lexaloffle.com/bbs/?tid=35608

I got curious and wanted to know if it was possible to recreate simple text that is chosen from random letters via the walking distance between the points when a match is made.

While I don't think this is at all useful for compression, it is interesting perhaps for use in encryption, secret messages, and your classic magic super decoder ring.

Actual code is really small, but it's chock full of helpful remarks.

Here it is:

-- secret decoder with random
-- written by dw817

-- simple wait for (o) key
function key()
  repeat
    flip()
  until btnp(4)
end

-- character set to use
char=" .abcdefghijklmnopqrstuvwxyz"

-- secret text, change to
-- your liking
t="the key is under the tree."

-- store the encrypted lookup
-- table here.
decod={}

cls()

-- force all random numbers to
-- follow this seed.
srand(1)

-- get length of string char.
-- we ask for it twice in the
-- code so this is convenient.
l=#char

-- starting position for lookup
-- table.
p=0

-- go through each character of
-- the secret string.
for i=1,#t do

-- pull out a single character.
  c=sub(t,i,i)

-- reset iterations needed to
-- find a match.
  n=0

  repeat

-- retrieve a random number to
-- use in finding a matching
-- character with our secret
-- string.
    r=flr(rnd()*l)+1

-- count the number of times it
-- takes.
    n+=1

-- keep looping until we get a
-- match.
  until c==sub(char,r,r)

-- match ? output the results.
  print("char="..c.." index="..i.." iterations="..n)

-- simple delay.
  flip()

-- record the time it took in
-- our lookup array.
  decod[p]=n

-- reset time.
  n=0

-- increase index for lookup
-- table.
  p+=1

-- do every single character
-- from secret string.
end

-- wait for (o) key.
key()

cls()
?"ready to decode:"

-- reseed our random number.
-- important !
srand(1)

-- reset position in lookup
-- table.
p=0

repeat

-- loop for length of lookup
-- table in elements.
  for i=1,decod[p] do

-- get a random number the
-- length of the chars used.  
    r=flr(rnd()*l)+1

-- keep looping the same number
-- of times it took to find
-- each character matching
-- initially.
  end

-- print out each newly
-- randomly generated
-- character.
  print(sub(char,r,r),p*4,64)

-- bit of a pause.
  flip()

-- increase position in lookup
-- table.
  p+=1

-- keep looping until we have
-- covered every character.
until p==#t

-- neat, print at bottom.
print("",0,120)

-- loop forever
repeat
  key()
until forever

The output to start with is the character we need to encode, the next is the index, the next is the time it took for RND() to randomly pick the correct matching letter.

After the "ready to decode:" then it just reseeds the same random seed and recreates the event based entirely upon the number of iterations needed to randomly pick the correct letters again.

Really something to see !

And it actually runs faster than this, too. Take out the FLIP() after each PRINT statement and it's off like a shot.

P#68725 2019-10-10 17:30 ( Edited 2019-10-10 18:19)

[ :: Read More :: ]

Man I'm tired. Aren't you tired ? Good day of coding indeed. Even busier day tomorrow - but no time for coding then.

And then this evening I started messing with the RUN command, thinking I could clear all variables but start running code at a different location and got this:

::here::
print"*"
flip()
run(here)

Got it all typed in ? Good cause soon as you run it WHAMMO, not only does it crash it exits the whole blooming PICO-8 system like you pressed ALT-F4 ! Wow.

Any ideas what's going on here ?

P#68669 2019-10-09 04:37 ( Edited 2019-10-09 15:18)

[ :: Read More :: ]

dw817's BOOK READER AND WRITER

br
by dw817
Cart #br-1 | 2019-10-08 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
6

First off, converting a book to a cart (not just for Pico-8) is not a unique idea.

I originally saw this being used back for Gameboy Color many years ago by Jeff Frohwein. At the time he was using a font very similar to ZEP's at a 3x5 pixel scale, but also included a distorted 3x4 letters for lowercase. Surprisingly it had 32k of storage for the story, so back then it was even more capable of storage than Pico-8 is of today.

There have been countless Bible programs for the pc which claim not only to contain the entire Bible but also have a search routine so you can look for certain passages and entries.

Today I use a bookreader on both my cellphone and portable PSP handheld game unit especially for the works of Arthur C. Clarke.

So ... this idea is not new and has in fact been tackled by many people long before the Pico-8 even existed. I have many interests myself, databases and compression just being a few. I was eventually going to get around to writing a book writer and reader, and here it is.

Having looked at dddaaannn's excellent version of a Pico-8 bookreader found HERE:

https://www.lexaloffle.com/bbs/?tid=2776

I realized I would be wanting to write one that would be simpler and not as complex or require much work for others to make use of my libs. And it may not compress as well, only(62-68%) but it would certainly contain everything in the single code needed so anyone could not only read the story enclosed but additionally add their own on top of it and compile for their own use.

And in less than 260-lines of source-code. That and not require any external batch files, Python files, manual compression, or what have you.

Nope ! It's ready to run right out of the box, batteries included. :)

First off when you run it you get a chance to read a bit of Alice In Wonderland. Use the UP and DOWN arrow keys to navigate by sentences and the LEFT and RIGHT to navigate by pages.

Notice you have a blue and red marker. The blue marker shows where your current bookmark is and the red marker shows where you are reading in the story.

Press (X) to set the bookmark and (O) to jump to it. Bookmarks are recorded so even if you run the program again later, it will remember that same bookmark you gave it.

In the code itself, it's very simple.

Set MODE to 0 (zero) if you just want to clear out the book RAM space so you can examine for yourself it truly is cleared.

Set MODE to 1 (one) and it will take whatever is in string variable STORY and both compress and stuff it all up in memory using up to 12288 bytes maximum for it.

Set MODE to 2 (default) and you can use the book reader included in the same program to examine your book.

Memory contents 0-1 is length of book.
Memory contents 2-3 is the current position of the bookmark.

And both of these elements are handled automatically in the code so you don't need to worry about them.

Also because this cart is self-modifying, once you compress a book of your choosing via the STORY variable, you can save off the .P8 or compile to EXE or whatever and it will automatically contain the story you put in there.

It should also be possible to write the code to handle more than one story here, you know, like Aesop's Fables, so you have a list of stories to choose from. Depending on the interest shown in this, I'll consider it.

P#68648 2019-10-08 17:18 ( Edited 2019-10-09 02:59)

[ :: Read More :: ]

dsm
by dw817
Cart #dsm-0 | 2019-10-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

Thought I would put this out.

I've seen quite a few platformers up to now. Only a few of them use dual scrolling maps.

What is that ? Try out the cart to see for yourself.

Very small coding. Uses _INIT() and _DRAW(). Hit arrow keys left and right to scroll.
Also wraps correctly. Method is included in the code.

HOPE THIS HELPS !

P#68535 2019-10-05 18:56 ( Edited 2019-10-05 20:37)

[ :: Read More :: ]

Before I set out on a long journey of code, I wanted to know if Pico-8 had the ability to do something like this:

a=sum("(3+4)*2")
print(a)

Where the answer would come back 12. And yes, the statement needs to be in a string and be able to handle one or more parentheses math.

The TRS-80 could do this:

INPUT A$
PRINT A$

And B4GL could as well.

INPUT A$
CODE("PRINT "+A$)
P#68477 2019-10-04 20:45 ( Edited 2019-10-04 21:15)

[ :: Read More :: ]

Was curious to know if this was a problem ?

And possibly for others who need exact math in their calculations.

P#68461 2019-10-04 18:18 ( Edited 2022-03-20 19:09)

[ :: Read More :: ]

This may be old hat to you veterans, but is there an easier way to look for a non-value than this ?

function sum(a,b)
  if a==nil or a=="" or b==nil or b=="" then
    return
  end
((rest of function)
end
P#68453 2019-10-04 16:19 ( Edited 2019-10-04 18:14)

[ :: Read More :: ]

cds
by dw817
Cart #cds-1 | 2019-10-04 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

Hmm ... You press ENTER in the BBS and it pauses, okay, run it local or use the spacebar instead.

Also, use the "=" as the backspace key and the "[" key for letter P.

As you know or should by watching how to write game in Pico-8 or doing so yourself, there is a nifty function called FGET() which will let you retrieve whether or not up to 8-flags are being set for a sprite of your choosing.

You can see pointing right at them HERE.

So how do they work ? Very simply. You click on them, up to 8 and using the command FGET followed by the sprite # you get the value of TRUE or FALSE whether or not that particular flag # (0-7) is set.

Not bad, but it could be better. That's where I come in with my new code. :)

So what does it do ?

Well for one thing is it lets you add a lot more definition and ease of retrieval for your sprites.

For instance, here is the string generated by the builder. You don't need to modify the string manually as I've created a program to edit each individual sprite, but it's still important to see what it looks like:

0[blank[[1[player[[2[floor[[3[wall[w[4[switch[[5[up[w[6[down[[7[treasure[w[8[empty[w[9[note[w[10[frenzy[[11[home[[12[zap[[17[blu[[18[bld[[19[bll[[20[blr[[63[marker[[

The data is separated into 3-parts. The first is the sprite # to contain this special data. The next is the name of the sprite, up to 8-chars you remember. The next is any sprite flags that exist for that sprite, and there can be up to 52 in any order for each sprite. You will see some of them have "W" set meaning Wall. So while you can name the sprites anything you want, you can also individually switch on and off the 52-flags available for them.

So what are the 52-flags ? That would be these:

.!?,;:#$%&-+*/=()<>{}|~^_@abcdefghijklmnopqrstuvwxyz

Assume in Pico-8 that these are uppercase. Why no digits ? Because if you call FFGET() with digits it assumes that you are requesting either the text name or status of the flags based on your numeric entry. Let's continue.

Now run the program above and select a sprite with the arrow keys, press ENTER and you can enter an up to 8-character name for it.

Press ENTER again and you can hit any of those characters you see below and that becomes a flag. This would be real nightmare to do with numbers and a modified FGET() though, right ?

Not to worry.

You see, the way I set it, you can retrieve all the following:

PRINT FFGET(number)
ANSWER: text name of that sprite.
PRINT FFGET(name)
ANSWER: number of that sprite on the sheet, zero being the first.
PRINT FFGET(1st character of name)
ANSWER: also the same number

Let's pause for a second. That last one is a little tricky. If you have more than one sprite that you have named with the same beginning character, it will only choose the last one calculated. It's not a reliable method if you have more than 26-sprites and you should choose the full-name or number each time in your code if you have dozens of sprites with definitions. Okay, let's continue. How are the flags handled ? Quite simply.

PRINT FFGET(number),(number)
ANSWER: the condition of whether that sprite #'s flag # is TRUE or FALSE
PRINT FFGET(name),(number)
ANSWER: same as above
PRINT FFGET(number),(single string character of flag)
ANSWER: same as above
PRINT FFGET(name),(string character of flag)
ANSWER: same as above

Let's see this in action with the sprite, WALL.

Quite a bit is happening, first off the total number of sprites (range) is 63 by printing SPR_TOTAL.

Then we are printing SPR_FLAGCHARS which are the 52-choices available to set flags for that individual sprite, ON or OFF, TRUE or FALSE.

Next is SPR_FLAGS which as described above is the string you need to copy to your code to have these flags set for your sprites.

Now we're using FFGET(). The wall is sprite #3. 48 is the letter "W" from the table. And you can see how it's possible to mix and match them quite thoroughly and still get the results you want.

If you only have one argument for FFGET() though, if it's a number it will retrieve the name of the sprite. If it's the name it will reverse and give you the number.

Example, to plot the player:

spr(ffget("player"),x,y)
or
spr(ffget("p"),x,y)
provided you only have one sprite name that begins with "p"

And that's it !

For your use, IMPORT your own sprite table. Run the program. Set your flags. Press "\" to save to clipboard. In a separate PICO-8 task (you should have 2 running). PASTE that string at the top of your _INIT() code. Then copy that one line in the first cart, the one called SPR_INIT(). Call that from your _INIT() code.

And you're done !

This is a considerably more robust flag system than PICO-8 came with. This demo also uses 1% of your onboard memory so it should work fine for you. I hope you use it and if you do, please let me know. Would love to see how you are getting on it.

And yes, those sprites included - I plan to make a game sometime later demonstrating the use of this new sprite library so no borrowing them for your projects just yet. :)

If you have any questions, and you might as this is a pretty busy upgrade going on here, feel free to let me know.

P#68427 2019-10-04 00:21 ( Edited 2019-10-04 03:45)

[ :: Read More :: ]

Alright so you've been using PICO for a-while now and have gotten used to the limitations on the sound. But then occasionally you come across a snazzy cart that has sound you are CERTAIN is just not possible with the limitations of Pico-8, or so you think.

So what gives ?

Well let's see if we can discover what's going on. First off save off the work on your current cart and REBOOT.

Let's start with a clean slate. Press the ESC key and ALT-RIGHT arrow key three times and TAB until you are at the sound editor.

Let's start with something basic. The rain sound. To make this, type out the following. You can create that "C" with letter Z.

Then click on the right-most number of LOOP to 1 so it shows LOOP 00 01 and press SPACEBAR to hear it.

Familiar. But is that as low pitch as the sound can go ? Well, yes and no.

Let's now discover something new. Hit SPACEBAR again to stop playing. Now, do you see that tiny little button just below the 2nd number for LOOP. Well, click on it.

Now this is different ! Your waveforms have been replaced with digits now 0-7 and you can see the button is active as it is GREEN.

Hit = and TAB to go to the next sound. From here, type out:

NOTICE the center number is no longer PINK but GREEN. This is a special case.

Set the loop here to 00 and 01 like the first sound and press SPACEBAR.

Well there's a sound you haven't heard in PICO before. So what's going on here.

When you use GREEN for your note instead of PINK you will be using THAT sound # as the instrument itself. In this case, you can see the zero is green so it means we are using the 1st sound as OUR instrument and are telling it to play it at an even lower pitch.

For low sounds you likely won't get much improvement as the audio is pretty raspy to begin with. But for high-pitch ? Well, let's try an experiment, shall we ?

Hit = and TAB again to go to the 3rd page for sounds. This time we're going to leave the LOOP at 00 and 00, but we ARE going to do something tricky.

Try this. First off hold down the "." key until your SPD is 255. We want it to play a good long time. Now type out the following:

Let's take a look at it letter per number.

It has a C so that's just the note. The next is is pitch, high as it will get. The GREEN number says to use - well - to use THIS sound as its instrument. This oughta be interesting. The next is 7, loud, and the last, the warble effect.

Get ready to hear a sound you've never heard in PICO before ! Press SPACEBAR to hear it.

Hope that didn't scare the cat ! :D

What's going on here ? Well, you're doing a feedback essentially. Like when a microphone gets too close to the speaker. You get this interesting warbling feedback effect. You could also get this trying to tune an AM radio.

So let's recap. The green number then means to use the SOUND # (0-7), sorry there are no more, to use as an instrument. So ... How could we use this to our advantage ? We've still got a bit of space. Let's do something fancy indeed.

If you have trouble typing this in, there's a copy of this cart at the end of the document.

Now on the next page have the following:

Notice that we have speed here set to 255 as well. So what do you think will happen ? Press SPACEBAR to play and find out.

Ah ! So it is indeed possible to play a sound that has tones as a single instrument itself and most importantly CHANGE THE KEY it is playing in.

And of course you can play something really high pitched as the instrument and then use a 2nd sound to play it even higher pitch getting some interesting sound effects not possible before this.

What amazing sounds will you discover ? Feel free to share.

Here is the sound set I put together.

Cart #jumugujido-0 | 2019-10-03 | Code ▽ | Embed ▽ | No License
1

HOPE THIS HELPS !

P#68406 2019-10-03 17:14 ( Edited 2019-10-03 19:34)

[ :: Read More :: ]

Yep, I'm still working on my Sprite/Flag routine.

Yet I left one of my other items running in the background in a separate Pico-8 tab last night, awoke to see that it said:

OUT OF MEMORY

Well the next morning I cleared the slate and started new code for it:

cls()
print"testing"
repeat
until forever

About 12-hours later it crashes and says:

OUT OF MEMORY

Now I don't think there's any recursion involved in this, but if it's running out of memory just by doing a loop, it could be a problem for others coders, right ?

And yes, I know "forever" is a NIL statement.

Nonetheless for it to crash, thoughts ?

P#68336 2019-10-02 00:31 ( Edited 2019-10-02 01:14)

[ :: Read More :: ]

Cart #map2bbsimage-1 | 2019-09-28 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2


To load this, in PICO-8 type:

load #map2bbsimage-1

[8x8]

[8x8]

MAPPER2BBSSPR(X1,Y1,X2,Y2)

This function will take coordinates from a cart of your choosing and let you specify from your MAPPER (x1,y1,x2,y2) where x1,y1 is top-left-hand corner of your map and x2,y2 is bottom-right-hand corner of your map to convert it to a BBS image that can be pasted in the forum.

It also clears the screen and shows you what was transferred so you can be certain you have the right image.

This is useful for collaborations on bigger projects and demos so you can share what you are working on in the mapper without having to use screen-capture, multiple pastes because it goes past the screen, or even lose sharpness or clarity because of a dithered resize.

Sample sprites and mapper data are included to get you started. Function is one-line so just copy that one-line to your project and run it from there.

IF YOU USE PLEASE LET ME KNOW !

P#68223 2019-09-28 14:31 ( Edited 2019-09-28 20:12)

[ :: Read More :: ]

as
by dw817
Cart #as-0 | 2019-12-31 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

TO LOAD THIS CART in Pico-8 immediate mode, type:

load #as]

(12-31-19) Added youtube video comparison.

It's difficult to emulate some of the wondrous things that are done in arcade games. One of which I was especially fond of is when Galaxian first made the scene as a space shooter. It had tiny stars that were colored and they flickered perfectly.

Here now is one function to do just that for you. Include in any of your space shooters. Just add to _draw() or _update(). Fire and forget. You don't even need code to initialize the stars as this is also covered in my one function.

Compare with original:

HOPE THIS HELPS !

P#68205 2019-09-28 01:02 ( Edited 2019-12-31 18:44)

[ :: Read More :: ]

Cart #str2board-0 | 2019-09-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

This program may not be too useful for you Pico-8 veterans but may prove instrumental to those learning the system or want an easy route to build their own mapper.

Obviously you can use the MAPPER if you want, but if you don't want to or can't, you may find this code to be of interest.

Here is the top of the source to show you what is going on in it.

As you can see it is a single string, 240-characters in length that uses only the special characters for Pico-8. If you check out the sprites you have:

Where you can replace each letter of the alphabet here with your own custom image. Then in the source editor, press SHIFT followed by that letter to enter in that character for the string in your board.

Run the program to see the results and build your own original game around this.

IF YOU USE PLEASE LET ME KNOW !

P#68201 2019-09-27 22:03 ( Edited 2019-09-28 19:07)

[ :: Read More :: ]

vvm
by dw817
Cart #vvm-6 | 2019-09-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1


To load this cart, in Pico-8 immediate mode type:

LOAD #VVM-6

UPDATE: 09-27-19

  • Sped up load/save to external file process considerably by using internal temporary storage.
  • Converted loose initialize to function.

  • Added "Skeleton" file to make it easier for others to use. Includes the only 3-functions you need to make it work, but for loading and saving. Found HERE:
    Cart #vvm_skel-0 | 2019-09-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
    1

-- skeleton file
function _init()
  initvar()
end

function _update()
  var.test="ready"
  var2file("*")
  stop()
end

function _draw()
end

function initvar()
function var2file(filename)
function file2var(filename)

To load this cart, in Pico-8 immediate mode type:

LOAD #VVM_SKEL-0

UPDATE: 09-26-19
Added ability to recall all software changes to sprites,mapper,sounds, and music even if you change them via POKE() in your code. Before after you loaded or saved your VARS it would only reset to what you have default in your cart. Code is a little slower because of this but works fine. New temporary file "_" is created because of this - but data is not affected.

. . .

Back when PICO-8 first came out, it was announced that you could load and save externally 64-numbers per cart. And life was good.

Then someone realized that this is actually 256-bytes and wrote routines to directly access that memory. And life was better.

Another person took that and said that 256-bytes could be broken down to 2048-switches. 8 bits per byte. And that was an interesting find to say the least.

Now me ? I've always been interested in compression - ever since I created S2 those 20+ years ago and wrote in it, that's right, the same name but a different method, a Virtual Variable Minder to keep track of all of my player and companion attributes and inventory.

I've also been experimenting with memory storage and recall in Pico for years now. At one point I wrote code that let you save up to 4096-bytes of memory at the cost of half your sprite space. It was good but the disadvantage was that you could only have one-save file per cart. I know this could be improved upon if I worked at it.

So now that ZEP has finally fixed the memory problem I was experiencing in an earlier version of PICO, I am successful - and do have a good grasp of how to work with up to 12288 bytes of memory that be both loaded and saved to an external file and touches no sprites, no mapper, no sound, and no music memory. And you can have as many as you want. You will find how in the routines I wrote here.

Now it is only recently I have discovered the use and power of "Variable dot." That is, any variable followed by the period key. The real advantage is that you can set any variable with it and later recall all the variables that match the prefix with my DLLs (and that's what I'm calling these routines).

In this, I have written 2 useful functions. One of which will save all your vars to any filename you want. Works everywhere:

  • immediate mode
  • EXE export
  • run in Splore
  • run in Lexaloffle's BBS
  • offline HTML export

It truly does work everywhere. And you can still have any number of files no matter the port.

No need for messy arrays, pokes, or anything like that. I have done all this work for you. Here are some examples of variables that can be loaded and saved easily in one pass.

var.name="george"
var.newname=""
var.hits=100
var.maxhits=250
var.expr=0
var.encounterrate=2.25
var.map={}
for i=0,15 do
  var.map[i]=i*3
end
var.equip={}
var.equip[2]="bronze sword"
var.equip[41]="silver armor"
var.equip[836]="wooden shield"
var.equip[1531]="copper helmet"
var.equip[25493]="leather boots"
var.flag={}
var.flag["key"]="gold"
var.flag["wand"]="ruby"
var.flag["apple15"]="delicious"

As you can see you can have quite non-standard variables as well. To save these call the function, VAR2FILE(filename). If you just want to view all the variables for debugging, choose the filename of "*" instead.

To load back your variables (and it doesn't need to be the same cart), call the function FILE2VAR(filename) where the filename is the same as the one you chose above.

And YES this does mean that you can indeed save multiple files since the filename can be anything at all and well exceed 65536 bytes of storage or even more.

There is one catch, I am using the "{" and "}" keys as markers for variable data storage and recall. Do not use these two-characters in any capacity for strings or string arrays. You do that and my program will work just fine.

I am also adopting a new stance. Years ago back in BlitzMAX DLLs were bandied about quite a bit. These were very popular often over standard released sourcecode in that you could "fire and forget" without ever having to worry about the actual source-code itself.

Therefore I am hanging up the cape of the dw817 laboratory. Instead it will be the dw817 Magic Shop. Good powerful routines but each in one magical line of code instead of 20-30 with massive remarks like I did earlier.

So too have I done that with these functions. They are each only one-line long and written about as small coding as is possible for me. You copy those two-lines plus the one line to initialize your "VAR." and you're DONE. No need for anything else - should work in any program and in any capacity.

Thanks especially to those who helped me understand dot variables and how to view them all via PAIRS(). I could not have done this without you !

Included now is a full cart demonstrating its ability to both load, view, and save. Notice when the variables are viewed for debugging that I have made use of { } in data separation.

IF YOU USE PLEASE LET ME KNOW !

P#68171 2019-09-27 00:45 ( Edited 2019-09-28 19:05)

[ :: Read More :: ]

I had discovered where the configuration file for Pico-8 was for binary export and came across an option in there:

fullscreen_method 1 // 0 maximized window (linux) 1 borderless desktop-sized window 2 fullscreen

Whatever you do DO NOT choose option 2 and run your cart. I had thought hardware snap was a thing of the past but apparently it's possible to do in Pico-8. You do NOT want to choose this as your monitor literally SNAPS to try and match the hardware resolution - which mine couldn't so the whole keyboard and mouse locked up and garbage appeared on my screen of other previous window tasks.

Fortunately I managed to shut down my computer and reboot. In the past techniques like this could physically damage your monitor and definitely royally crash your computer.

ZEP may I wholeheartedly recommend you REMOVE this option at least for Windows executables. No Windows software today should ever need hardware snap with the advanced graphic cards we have.

P#68102 2019-09-24 15:46 ( Edited 2019-09-24 21:19)

[ :: Read More :: ]

Hello.

Could someone help me with this please ? I'm trying to understand how this works.

var={}
var["playhp"]=500
var["playname"]="patrick"
var["wepname"]="dagger"
var["wepstr"]=2

for i in all(var) do
  print(i.." "..var)
end

And yes, I know I can use:

var={["playhp"]=500,["playname"]="patrick",["wepname"]="dagger",["wepstr"]=2}

But I want to be able to iterate each item per line and in any order, and the ability to remove them as well.

var["playhp"]=nil

And to recall a value: print(var."playhp") returns 500. And ability to recall a value be reference:

varname="playhp"
print(var.@varname) also to return 500.

And print(#var) to return 4, currently returns 0 (zero).

Thanks in advance !

P#68005 2019-09-22 21:28 ( Edited 2019-09-22 23:01)

[ :: Read More :: ]

Cart #yield_fireball-0 | 2019-09-22 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

You ever have that moment when somebody tells you something and you SORT OF get it but not really, and then later, maybe a day or two you cry out, "Ah ha !" because then you understand it ?

Well I'm not going to claim full knowledge of the YIELD() command, but I will tell you what it CAN do - at least for me.

I can take any program I've written to date and make it OOPS very simply.

Replace all FLIP() with YIELD(), then make a coroutine to run my MAIN() function. Done.

But it goes beyond this. Since I can now join the ranks of _DRAW() and _UPDATE() this means I can write a custom background engine that operates exactly as I like it.

In this case for this example you can hit "Q" and bring up Quick Debugger which shows memory usage and how much of the CPU is being tasked. You can also hit [ESC] and type RESUME to leave off where you where.

Before YIELD() I couldn't do either of these things nor read the CPU. Now I can. This does herald the END of FLIP() for me and the very welcome arrival of YIELD().

What does this mean for you ? YIELD() does not just exit a function it retains the exact position when you return even if you were nested in a whirl of FOR/DO, IF/END, and REPEAT/UNTIL statements. It also retains all local variables and values at the point you exit and return. That is immensely powerful.

Giving credit where credit is due. I found out about YIELD() from freds72 HERE:
https://www.lexaloffle.com/bbs/?tid=31359

and MBoffin HERE:

https://www.lexaloffle.com/bbs/?tid=35381

. . .

More and more I begin to appreciate this Pico-8 system and daresay it is the most powerful programming language I have ever come across.

P#68002 2019-09-22 16:47 ( Edited 2019-09-22 21:36)

[ :: Read More :: ]

Cart #implosion-1 | 2019-09-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
5

Years ago I had written a QBasic program for Gina in Taiwan. In it, it imploded the map of Texas along with a greeting. When you ran it, it had the pixels come from all sides of the screen to implode the image I put in there.

Now you can do the same thing in Pico-8 !

Create any picture you want, call initexplosion() then explosion(1,flag) Flag to 1 if you want to skip seeing the explosion and only want to calculate for it. Then you are ready. Now call explosion(-1,0) to see the neat implosion effect of the image you put in there.

P#67980 2019-09-21 21:22 ( Edited 2019-09-21 21:24)

[ :: Read More :: ]

I first off wanted to let you know that I was just experimenting recording some .GIFs in PICO when I noted that the last .GIF I made was 6.49mb in size.

I loaded this up in VirtualDUB to check each frame in it, to make sure it looked alright, and then tried saving it back as an EXPORT .GIF to compare filesizes.

The filesize THEN was only 209k ! A 97% reduction !

I compared both. None miss frames, none have any distortion. They are the same EXCEPT that VirtualDUB has some massive compression going on there !

So ... Zep, someone, anyone ? the .GIF saver in current PICO-8 can definitely be optimized. No doubt about it. VirtualDUB was written 19-years ago - so it's not something new.

I can't upload the 6.49mb GIF in comparison here, says the filesize is too big.

Here is the 209k GIF though so you can see it's not missing anything. There's definitely good compression going on there !

I guess the good news is I've introduced a program (VirtualDUB) that will let users now save .GIFs of their cart directly in the BBS that can exceed well into minutes as they are so small in filesize as they are 3% the size of their original - and have the ability to edit out frames they don't want included in the presentation .GIF.

VirtualDUB is 100% Freeware and you can find it HERE:

http://virtualdub.sourceforge.net/

HOPE THIS HELPS !

P#67977 2019-09-21 18:36 ( Edited 2019-09-21 21:36)

[ :: Read More :: ]

Cart #xor_flower-0 | 2019-09-19 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

Years ago computers had very little memory. I am reminded of the Apple ][ computer which although having 2-HIRES graphic pages each 8192-bytes in size with a resolution of 280x192 B&W pixels, you only had about 16k of RAM space if you used both of them for your program.

The original method was to plot an image on one page while viewing the other, then swap the two so you were always plotting on one while viewing the other. Yet this technique cost two HIRES pages of memory.

So a new method was adopted to handle plotting sprites and graphics over existing static images, and that method was called XOR.

On the Apple for instance you could plot a shape with XOR dots, that is for every pre-existing black dot you plotted on, it would appear white. Likewise if you plotted on a previously existing white dot, the plotting color for your dot would be black.

To erase the shape you would repeat the drawing exactly which would also recover the background beneath it - and this method only required the use of one HIRES page instead of the need for two so you could program in an additional 8192-bytes of code for your program, critical to many video-games that many years ago.

XOR also does some interesting graphic effects. If you XPLOT a line and then plot ANOTHER XOR LINE almost exactly like it but at a slightly different angle you can an interesting kind of warped box effect or flower as you see here.

Now as you cannot XPLOT a LINE in Pico-8, I wrote a routine to do just that for you called PLINE using coordinate arguments the same as LINE()(x1,y1,x2,y2).

So this cart is twofold, not only do you get a lovely mathematical flower but you can use this small coded PLINE() routine for your own works to have one target chase another, perhaps for your opponent to fire a shot at you despite where they are on the screen, or even just to simply draw a line changing color mid-step as you go.

It's up to you !

P#67910 2019-09-19 23:26 ( Edited 2019-09-19 23:43)

View Older Posts